//2009/08/21 11:31:59
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class MarbleNecklace
{
public:
    string normalize(string necklace)
    {
		vector<string> v;
		for(int i=0; i<necklace.size(); i++)
			v.push_back(necklace.substr(i) + necklace.substr(0,i));
		reverse(necklace.begin(), necklace.end());
		for(int i=0; i<necklace.size(); i++)
			v.push_back(necklace.substr(i) + necklace.substr(0,i));
		sort(v.begin(), v.end());
		return v[0];
    }
};
